package com.arturjaneczko.services.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;

public class P {

	private final File file = new File(getClass().getClassLoader().getResource("ui.properties").getPath());
	private static Properties properties;

	private void loadProperties() throws FileNotFoundException, IOException {
		InputStream is = new FileInputStream(file);
		properties.load(is);
		is.close();
	}

	@SuppressWarnings("unused")
	private void saveProperties(final String key, final String value)
			throws FileNotFoundException, IOException {
		OutputStream os = new FileOutputStream(file);
		properties.setProperty(key, value);
		properties.store(os, null);
		os.close();
	}

	public static Properties getProperties() {
		return properties;
	}
	
	public static String r(String key) throws FileNotFoundException, IOException {
		properties = new Properties();
		new P().loadProperties();
		return properties.getProperty(key);
	}

}
